<?php

namespace System\library\logger;

/**
 * <b>Class</b> :        Formater<br>
 * <b>Fonction</b> :     Factorise les formaters pour le logger
 * <br>
 * @version              1.0
 * @author               Steuf
 * @version              2.0<br>
 *                       Ajout de la phpdoc<br>
 *                       Typo correction
 * <br>
 * @author               Dread <dreadlokeur@gmail.com>
 * @license              Licence publique générale GNU http://www.gnu.org/licenses/gpl.html
 * @copyright            Copyright 2011 - MidichloriansPHP and contributors
 * @package              System
 * @subpackage           library\logger
 */
class Formater {

    public static function factory($formater, $args = array()) {
        if (!class_exists('System\library\logger\formaters\\' . $formater))
            throw new \Exception('Formater "' . $formater . '"  don\'t exists');

        $formater = new \ReflectionClass('System\library\logger\formaters\\' . $formater);
        if (!in_array('System\library\logger\IFormater', $formater->getInterfaceNames()))
            throw new \Exception('Formater "' . $formater . '" must be implement System\library\logger\IFormater');
        return $formater->newInstanceArgs($args);
    }

}

?>
